Text Colors

I would like to know if there is possible to show differences between two texts in a colourful manner in a text attribute. I used the diff function with the {//cf1} murkup and with RichText but it still appears black and white.

Is there any solution ?
Manilla - Wed Apr 01 09:15:58 EDT 2009

Re: Text Colors
SystemAdmin - Wed Apr 01 10:05:38 EDT 2009

Manilla,
I import the attached document to highlight text in different colours and using one of the Kitchen scripts (Kitchen > Columns > Display RTF attributes in Column...) it shows the following code:

{\rtf1\ansi\ansicpgl252\deff0\deflang1033{\fonttbl{\f0\froman\fprq2\\fcharset0 Times New Roman;}{\f1\fnil\fcharset0 Tahoma;}}{\colortbl ;\red255\green255\blue0;}\viewkind4\ucl\pard\highlight1\lang2057\f0\fs24 Colour Highlights - Yellow\highlight0\lang1033\f1\fs1660\par}

It's not what you're after, but some of the code might provide some clues...
Simon Haydn BSc (Hons)

Requirements Controller
Marshall Aerospace (UK)
Attachments

attachment_14236182_Colour_Highlights.doc

Re: Text Colors
djakad - Wed Apr 01 10:53:32 EDT 2009

Yes, it can be done. Here are a few tips and examples:

1.) To get color text or color highlighting in a Layout DXL column or in a richText box in a dialog box, you need to understand and use some basic Rich Text formatting tags.
2.) At the start of every Rich Text block of text, you will need to include a "color table", defined by the "{\\colortbl; ... }" tag.
3.) Then, you will use the "color font" tags, such as "\\cf1" or "\\cf2" to color the text. Or, you will use the "highlight" tags, such as "\\highlight1" or "\\highlight2", to use a color highlight. The numbers refer to the colors defined in the "color table". You use "\\cf0" and "\\highlight0" to turn off colors.
4.) In a Layout DXL column, you must use the "displayRich(string)" command, to get the colors to show in the module window.
5.) In a richText box in a dialog box, you must use the "useRTFColour(DBE,true)" command, to get the colors to show in the richText box.

Here is a sample "color table" definition:
string xColorTable = "{\\colortbl ;\\red255\\green0\\blue0;\\red0\\green255\\blue0;\\red0\\green0\\blue255;\\red255\\green255\\blue0;\\red255\\green0\\blue255;\\red0\\green255\\blue255;\\red255\\green255\\blue255;\\red0\\green0\\blue0;}"

Here is the same color table, broken out with some // comments to explain it:
string xColorTable = "{\\colortbl ;"
xColorTable = xColorTable "\\red255\\green0\\blue0;" // red \\cf1 \\highlight1
xColorTable = xColorTable "\\red0\\green255\\blue0;" // green \\cf2 \\highlight2
xColorTable = xColorTable "\\red0\\green0\\blue255;" // blue \\cf3 \\highlight3
xColorTable = xColorTable "\\red255\\green255\\blue0;" // yellow \\cf4 \\highlight4
xColorTable = xColorTable "\\red255\\green0\\blue255;" // purple \\cf5 \\highlight5
xColorTable = xColorTable "\\red0\\green255\\blue255;" // light blue \\cf6 \\highlight6
xColorTable = xColorTable "\\red255\\green255\\blue255;" // white \\cf7 \\highlight7
xColorTable = xColorTable "\\red0\\green0\\blue0;" // black \\cf8 \\highlight8
xColorTable = xColorTable "}"

For colors in a Layout DXL column, you could do something like (using the xColorTable from above):
displayRich xColorTable "{\\cf1 This is red text. \\cf0\\highlight4 This is yellow highlight \\highlight0 }"

For colors in a richText DBE in a dialog box, you could do something like (using the xColorTable from above):
string xSample = xColorTable "{\\cf1 This is red text. \\cf0\\highlight4 This is yellow highlight \\highlight0 }"
DB xDB = centered("Colors in a richText DBE")
DBE xRichText = richText(xDB,"richText DBE:","empty",360,250,false)
realize(xDB)
useRTFColour(xRichText,true)
set(xRichText,xSample)
show(xDB)

I've attached a screen shot of the richText dialog box example. With this method, you can get 16.7 million possible colors (256^3). You will have to work your own code to get the text difference comparison.
Attachments

attachment_14236234_RichTextColor.jpg

Re: Text Colors
dpechacek - Wed Apr 01 10:54:11 EDT 2009

SystemAdmin - Wed Apr 01 10:05:38 EDT 2009
Manilla,
I import the attached document to highlight text in different colours and using one of the Kitchen scripts (Kitchen > Columns > Display RTF attributes in Column...) it shows the following code:

{\rtf1\ansi\ansicpgl252\deff0\deflang1033{\fonttbl{\f0\froman\fprq2\\fcharset0 Times New Roman;}{\f1\fnil\fcharset0 Tahoma;}}{\colortbl ;\red255\green255\blue0;}\viewkind4\ucl\pard\highlight1\lang2057\f0\fs24 Colour Highlights - Yellow\highlight0\lang1033\f1\fs1660\par}

It's not what you're after, but some of the code might provide some clues...
Simon Haydn BSc (Hons)

Requirements Controller
Marshall Aerospace (UK)

In the DXL Reference Manual, see the diff(Buffer result, Buffer source, string removeMarkup, string insertMarkup) function.

You can use these standard values for the markup.
removeMarkup = "\cf1\strike"
insertMarkup = "\cf2\ul"

AAI Services, Textron
dpechacek@sc-aaicorp.com
David.Pechacek@gmail.com

Re: Text Colors
dpechacek - Wed Apr 01 11:03:21 EDT 2009

dpechacek - Wed Apr 01 10:54:11 EDT 2009
In the DXL Reference Manual, see the diff(Buffer result, Buffer source, string removeMarkup, string insertMarkup) function.

You can use these standard values for the markup.
removeMarkup = "\cf1\strike"
insertMarkup = "\cf2\ul"

AAI Services, Textron
dpechacek@sc-aaicorp.com
David.Pechacek@gmail.com

Sorry didn't see that you tried the diff function. If you have it set up right you should see the colors. Make sure you're displaying the rich text string properly.

You're using displayRich(stringOf(resultBuffer)) right?

AAI Services, Textron
dpechacek@sc-aaicorp.com
David.Pechacek@gmail.com

Re: Text Colors
llandale - Wed Apr 01 14:00:53 EDT 2009

Far too complicated to go into here, but I had massive and systemic problems using 'diff' on strings intended either for MS-Word or re-insert into an Text attribute. There were far too many issues for me to remember and the solution is hopelessly convoluted, but some of the issues are: ] Raw text that contains things that look like rich text [ slashes and braces in the raw text ] complicated text markup requests [ EOLs and TABs in the raw text. Some of the solutions involve massive character and string replaces in the original text, then massive re-replaces back in the results string. Use richTextFragment() on the results. Adding spaces between the 'words' of the desired markup.

Yuuuuuuuck, but it works.

I can safely say this, when combined with my normal export-to-word fiasco, is by far the hardest to grasp when plowing through my massive library of functions. I don't even get it, and if I have to dive into it again it will take me a week just to grasp it, in spite of all the 'comments' I've tried to insert to explain things to myself.

>Louie

Re: Text Colors
Manilla - Thu Apr 02 05:57:05 EDT 2009

dpechacek - Wed Apr 01 10:54:11 EDT 2009
In the DXL Reference Manual, see the diff(Buffer result, Buffer source, string removeMarkup, string insertMarkup) function.

You can use these standard values for the markup.
removeMarkup = "\cf1\strike"
insertMarkup = "\cf2\ul"

AAI Services, Textron
dpechacek@sc-aaicorp.com
David.Pechacek@gmail.com

I don't want to color the text in a DBE window (I know this works).
What I want is to display the differences in a TEXT attribute in a column from a module.
I will show my exemple to make an idea of what I am trying:



Buffer buff1 = create()
Buffer buff2 = create()

bool ok;

string afis

for obj in (current Module) do
{
string obo = obj."YesNo" // Yes or No

buff1 = obj."Object Text"
buff2 = obj."TestText"
if (obj."Object Heading" "" != "") then
{
buff1 = obj."Object Heading"
}
if (obj."Object Text" "" != "") then
{
buff1 = obj."Object Text"
}

Buffer resBuf = create();
string result = diff(resBuf, buff1, buff2, "\\cf1\\strike ","\\cf2\\ul " );

obj."TestRichText" = richText resBuf
delete resBuf
}
delete(buff1)
delete(buff2)

----

string result = diff(resBuf, buff1, buff2, "\\cf1\\strike ","\\cf2\\ul " );

In this line eventhough I use the tags "\\cf1", "\\cf2" the differences still apear monochrome.

In this way I would like to make the text appear color if it is possible without using Layout DXL.
I attached you also a jpg file to understand better what I want to obtain.
Thank you !
Attachments

attachment_14236670_color.JPG

Re: Text Colors
djakad - Thu Apr 02 10:10:47 EDT 2009

Manilla - Thu Apr 02 05:57:05 EDT 2009
I don't want to color the text in a DBE window (I know this works).
What I want is to display the differences in a TEXT attribute in a column from a module.
I will show my exemple to make an idea of what I am trying:



Buffer buff1 = create()
Buffer buff2 = create()

bool ok;

string afis

for obj in (current Module) do
{
string obo = obj."YesNo" // Yes or No

buff1 = obj."Object Text"
buff2 = obj."TestText"
if (obj."Object Heading" "" != "") then
{
buff1 = obj."Object Heading"
}
if (obj."Object Text" "" != "") then
{
buff1 = obj."Object Text"
}

Buffer resBuf = create();
string result = diff(resBuf, buff1, buff2, "\\cf1\\strike ","\\cf2\\ul " );

obj."TestRichText" = richText resBuf
delete resBuf
}
delete(buff1)
delete(buff2)

----

string result = diff(resBuf, buff1, buff2, "\\cf1\\strike ","\\cf2\\ul " );

In this line eventhough I use the tags "\\cf1", "\\cf2" the differences still apear monochrome.

In this way I would like to make the text appear color if it is possible without using Layout DXL.
I attached you also a jpg file to understand better what I want to obtain.
Thank you !

Have you tried adding a color table to the beginning of your rich text?

Re: Text Colors
SystemAdmin - Fri Apr 03 05:32:00 EDT 2009

djakad - Thu Apr 02 10:10:47 EDT 2009
Have you tried adding a color table to the beginning of your rich text?

Try this:
diff(resBuf, oldBuf, newBuf, true)
*displayRichWithColor*(stringOf(resBuf))

Re: Text Colors
SystemAdmin - Fri Apr 03 05:33:42 EDT 2009

SystemAdmin - Fri Apr 03 05:32:00 EDT 2009
Try this:
diff(resBuf, oldBuf, newBuf, true)
*displayRichWithColor*(stringOf(resBuf))

That should have been posted as:
diff(resBuf, oldBuf, newBuf, true)
displayRichWithColor (stringOf(resBuf))

Re: Text Colors
Manilla - Fri Apr 03 05:56:32 EDT 2009

SystemAdmin - Fri Apr 03 05:33:42 EDT 2009
That should have been posted as:
diff(resBuf, oldBuf, newBuf, true)
displayRichWithColor (stringOf(resBuf))

displayRichWithColor should add an aditional column? It doesn't seem to work...
I can't change the font of the text in the column...I've tried the methods you told me but none seems to work

Re: Text Colors
DEHKB - Thu Apr 16 09:16:04 EDT 2009

Hi,

has anyone been able to get this to work? I tried to include the color table, but doesn't work

Cheers Harald

Re: Text Colors
SystemAdmin - Fri Jul 10 06:13:45 EDT 2009

DEHKB - Thu Apr 16 09:16:04 EDT 2009
Hi,

has anyone been able to get this to work? I tried to include the color table, but doesn't work

Cheers Harald

Hi, in case it helps:
I had a similar problem: text remained black on white background although colortable was defined (pasted the one from djakad).
Indeed, displayRich does not work, but the undocumented "displayRichWithColor" does the job:

displayRichWithColor xColorTable "{\\cf1 This is red text. \\cf0\\highlight4 This is yellow highlight \\highlight0 }"

--
Nick

Re: Text Colors
UchihaItachi - Sun Dec 22 22:22:18 EST 2013

dpechacek - Wed Apr 01 11:03:21 EDT 2009
Sorry didn't see that you tried the diff function. If you have it set up right you should see the colors. Make sure you're displaying the rich text string properly.

You're using displayRich(stringOf(resultBuffer)) right?

AAI Services, Textron
dpechacek@sc-aaicorp.com
David.Pechacek@gmail.com

Seems that the post is talking about a rich text box control that enables you to change the text color freely.

Re: Text Colors
Schollii - Thu May 19 09:30:56 EDT 2016

djakad - Wed Apr 01 10:53:32 EDT 2009
Yes, it can be done. Here are a few tips and examples:

1.) To get color text or color highlighting in a Layout DXL column or in a richText box in a dialog box, you need to understand and use some basic Rich Text formatting tags.
2.) At the start of every Rich Text block of text, you will need to include a "color table", defined by the "{\\colortbl; ... }" tag.
3.) Then, you will use the "color font" tags, such as "\\cf1" or "\\cf2" to color the text. Or, you will use the "highlight" tags, such as "\\highlight1" or "\\highlight2", to use a color highlight. The numbers refer to the colors defined in the "color table". You use "\\cf0" and "\\highlight0" to turn off colors.
4.) In a Layout DXL column, you must use the "displayRich(string)" command, to get the colors to show in the module window.
5.) In a richText box in a dialog box, you must use the "useRTFColour(DBE,true)" command, to get the colors to show in the richText box.

Here is a sample "color table" definition:
string xColorTable = "{\\colortbl ;\\red255\\green0\\blue0;\\red0\\green255\\blue0;\\red0\\green0\\blue255;\\red255\\green255\\blue0;\\red255\\green0\\blue255;\\red0\\green255\\blue255;\\red255\\green255\\blue255;\\red0\\green0\\blue0;}"

Here is the same color table, broken out with some // comments to explain it:
string xColorTable = "{\\colortbl ;"
xColorTable = xColorTable "\\red255\\green0\\blue0;" // red \\cf1 \\highlight1
xColorTable = xColorTable "\\red0\\green255\\blue0;" // green \\cf2 \\highlight2
xColorTable = xColorTable "\\red0\\green0\\blue255;" // blue \\cf3 \\highlight3
xColorTable = xColorTable "\\red255\\green255\\blue0;" // yellow \\cf4 \\highlight4
xColorTable = xColorTable "\\red255\\green0\\blue255;" // purple \\cf5 \\highlight5
xColorTable = xColorTable "\\red0\\green255\\blue255;" // light blue \\cf6 \\highlight6
xColorTable = xColorTable "\\red255\\green255\\blue255;" // white \\cf7 \\highlight7
xColorTable = xColorTable "\\red0\\green0\\blue0;" // black \\cf8 \\highlight8
xColorTable = xColorTable "}"

For colors in a Layout DXL column, you could do something like (using the xColorTable from above):
displayRich xColorTable "{\\cf1 This is red text. \\cf0\\highlight4 This is yellow highlight \\highlight0 }"

For colors in a richText DBE in a dialog box, you could do something like (using the xColorTable from above):
string xSample = xColorTable "{\\cf1 This is red text. \\cf0\\highlight4 This is yellow highlight \\highlight0 }"
DB xDB = centered("Colors in a richText DBE")
DBE xRichText = richText(xDB,"richText DBE:","empty",360,250,false)
realize(xDB)
useRTFColour(xRichText,true)
set(xRichText,xSample)
show(xDB)

I've attached a screen shot of the richText dialog box example. With this method, you can get 16.7 million possible colors (256^3). You will have to work your own code to get the text difference comparison.

Wow, awesome post, thanks for the info. Exactly the kind of detail I was looking for!